package com.xiaohong.websocket.client;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

public class MyWebSocketClient extends WebSocketClient {

    public MyWebSocketClient(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        System.out.println("连接成功！");
    }

    @Override
    public void onMessage(String s) {
        System.out.println("接收到服务端数据："+s);
    }

    @Override
    public void onClose(int i, String s, boolean b) {
        System.out.println("关闭连接"+s);
    }

    @Override
    public void onError(Exception e) {
        System.out.println("发生异常"+e);
    }

}
